package com.byteblogs.helloblog.config;

import feign.Feign;
import feign.Logger;
import feign.RequestInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @date 2019/9/1 0001
 **/
@Configuration
@ConditionalOnClass(Feign.class)
@AutoConfigureBefore(FeignAutoConfiguration.class)
@EnableFeignClients(basePackages = {"com.byteblogs.helloblog.integration"})
public class FeignConfig {

    @Autowired
    private FeignBasicAuthRequestInterceptor feignBasicAuthRequestInterceptor;

    @Bean
    public Logger.Level logger() {
        return Logger.Level.FULL;
    }

    /**
     * feign请求拦截器
     *
     * @return
     */
    @Bean
    public RequestInterceptor requestInterceptor() {
        return feignBasicAuthRequestInterceptor;
    }

}
